<template>
  <div class="request">
    <div>
      <input type="button" value="Post" @click="handleSendPost"/>
      <input type="button" value="Get" @click="handleSendGet"/>
      <input type="button" value="发送统一请求" @click="handleSend"/>
    </div>
  </div>
</template>

<script>
import axios from 'axios';

export default {
methods:{
  handleSendPost(){
    axios.post('/api/admin/employee/login',{
      username: 'admin',
      password: '123456'
    }).then(res => {
      console.log(res.data)
    }).catch(error => {
      console.log(error.response)
    })
  },

  handleSendGet(){
    axios.get('/api/admin/dish/60',{
      headers:{
        token:'eyJhbGciOiJIUzI1NiJ9.eyJlbXBJZCI6MSwiZXhwIjoxNzM4NDg3NTQxfQ.7Y1lnfOB9D2zPrCzi9kE1M5YlcqtcXdf3rROa8MV__4',
      }
    })
  },

  handleSend(){
    axios({
      url: '/api/admin/employee/login',
      method: 'post',
      data: {
        username: 'admin',
        password: '123456'
      }
    }).then(res => {
      console.log(res.data.data.token)
      axios({
        url: '/api/admin/dish/60',
        method: 'get',
        headers:{
          token: res.data.data.token
        }
      })
    })
  }
}
}
</script>
